﻿#include "CBeltCorrectRealInfo.h"
#include "CGlobal.h"

CBeltCorrectRealInfo::CBeltCorrectRealInfo(CDevDataBeltRealign* pDevDataBlet)
	: m_pDevData(pDevDataBlet)
{
	ui.setupUi(this);
	ui.labelName->setText(m_pDevData->m_sPointName);
	m_pRefreshTimer = new QTimer(this);
	connect(m_pRefreshTimer, SIGNAL(timeout()), this, SLOT(slotRefreshUI()));
}

CBeltCorrectRealInfo::~CBeltCorrectRealInfo()
{}

void CBeltCorrectRealInfo::refreshData(bool bRefresh)
{
	if (bRefresh)
	{
		m_pRefreshTimer->start(3000);
	}
	else
	{
		m_pRefreshTimer->stop();
	}
}

void CBeltCorrectRealInfo::slotRefreshUI()
{
	m_pDevData->m_pMutex->lock();
	//摄像头状态
	if (m_pDevData->m_pDevDataCam->m_bLogin == true)
	{
		ui.labelCamerState->setText(A2T("正常"));
	}
	else
	{
		ui.labelCamerState->setText(A2T("异常"));
	}

	//算法状态
	if (m_pDevData->m_nAlgState == 1)
	{
		ui.labelAlgState->setText(A2T("正常"));
	}
	else
	{
		ui.labelAlgState->setText(A2T("异常"));
	}
	//跑偏状态
	if (m_pDevData->m_bIsCorrect == true || m_pDevData->m_bIsCorrectTwo == true)
	{
		ui.labelCorrectState->setText(A2T("异常"));
	}
	else
	{
		ui.labelCorrectState->setText(A2T("正常"));
	}

	ui.labelLeft->setText(QString::number(m_pDevData->m_dLeftCurrVal * 10, 'f', 1));
	ui.labelRight->setText(QString::number(m_pDevData->m_dRightCurrVal * 10, 'f', 1));
	m_pDevData->m_pMutex->unlock();
}
